﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LingDong.IndexReader;
using System.IO;
using System.Diagnostics;

namespace LingDong.WordCluster
{
    class Program
    {
        static void Main(string[] args)
        {
            //File.Delete(Settings.OutputFile);
            using (Index index = new Index())
            {
                IndexCache.Init(index);

                Console.WriteLine("Noun term num: {0}", IndexCache.NounDictionary.Count);

                Stopwatch watch = new Stopwatch();
                watch.Start();
                int counter = 0;
                foreach (string term in IndexCache.NounDictionary.Keys)
                {
                    Cluster cluster = new Cluster(term, index);
                    cluster.Run();
                    Console.WriteLine(term);

                    if (++counter % 10 == 0)
                    {
                        Console.WriteLine("{0}, {1}s per term.", 
                            counter, 
                            Math.Round(watch.Elapsed.TotalSeconds / counter, 2));
                    }
                }
            }
        }
    }
}
